package com.inventory.form;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class CorporationFormValidator implements Validator {
	
	@Override
	public boolean supports(Class<?> clazz) {
		return CorporationForm.class.equals(clazz);
	}
	
	@Override
	public void validate(Object obj, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "corporation.name", "errors.corporation.name.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "corporation.drugLicenceNumber", "errors.corporation.drugLicenceNumber.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "corporation.address.addressLine1", "errors.corporation.addressLine1.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "corporation.address.city", "errors.corporation.city.required");
		
	}
}
